package com.cheng.mybatis02.service.impl;

import com.cheng.mybatis02.dao.BookMapper;
import com.cheng.mybatis02.entity.Book;
import com.cheng.mybatis02.service.BookService;

import java.util.List;
import java.util.Map;

public class BookServiceImpl implements BookService {
    private final BookMapper bookMapper;

    public BookServiceImpl(BookMapper bookMapper){
        this.bookMapper = bookMapper;
    }

    @Override
    public Integer getBookCount() {
        return bookMapper.queryCount();
    }

    @Override
    public Map<String, Object> getBookByIdToMap(int id) {
        return bookMapper.queryBookByIdToMap(id);
    }

    @Override
    public List<Map<String, Object>> getAll() {
        return bookMapper.queryAll();
    }

    @Override
    public Map<Integer, Map<String, Object>> getAllToMap() {
        return bookMapper.queryAllToMap();
    }

    @Override
    public List<Book> getBookByAuthor(String author) {
        return bookMapper.queryBookByAuthor(author);
    }

    @Override
    public int removeBookByIds(String ids) {
        return bookMapper.deleteBookByIds(ids);
    }

    @Override
    public int addBook(Book book) {
        return bookMapper.insertBook(book);
    }
}
